<?php $this->_extends('_layouts/main_layout'); ?>
<?php $this->_block('title'); ?>
<?php echo "Publishers"; ?>
<?php $this->_endblock(); ?>

<?php $this->_block('contents'); ?>
<div id="content" class="box">
	<h1>Publishers</h1>
	<div id="menu" class="box">
		<ul class="box">
			<li><a href="<?php echo url('publisher/add');?>"><span>Add</span></a></li>
		</ul>
	</div>
		<?php if (isset($infos)) 
				{
					foreach ($infos as $info)
					{
		?>
				<p class="msg info"><?php echo $info;?></p>
		<?php		}
				}
		?>
	<table class="full-size">
		<tbody>
			<tr>
				<th>Pub ID</th>
				<th>Pub Name</th>
				<th>Sub ID</th>
				<th>Sub Name</th>
				<th>Actions</th>
			</tr>
			<?php
				if(!empty($publishers)):
					$bg = false;
					foreach ($publishers as $publisher)
					{
			?>
				<tr <?php if ($bg) echo 'class="bg"';?>>
					<td><?php echo $publisher['id'];?></td>
					<td><?php echo $publisher['name'];?></td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>
					<a href="<?php echo url('publisher/addsub', array('pubid'=>$publisher['id']));?>">Add Sub</a>
					<a href="<?php echo url('publisher/edit', array('id'=>$publisher['id']));?>">Edit</a>
					</td>
					<?php
						foreach ($publisher['subs'] as $sub)
						{
					?>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td><?php echo $sub['id'];?></td>
						<td><?php echo $sub['name'];?></td>
						<td>
							<a href="<?php echo url('publisher/editsub', array('subid'=>$sub['id']));?>">Edit</a>
						</td>
					<?php
						}
					?>
				</tr>
			<?php
						$bg = !$bg;
					}
				endif;
			?>
		</tbody>
	</table>
</div>
<?php $this->_endblock(); ?>
